#include "Locker.h"

CCriticalSection::CCriticalSection(void)
{
	::InitializeCriticalSection(&m_criticalSection);
}

CCriticalSection::~CCriticalSection(void)
{
	::DeleteCriticalSection(&m_criticalSection);
}

void CCriticalSection::Lock()
{
	::EnterCriticalSection(&m_criticalSection);
}

void CCriticalSection::Unlock()
{
	::LeaveCriticalSection(&m_criticalSection);
}

CLocker::CLocker(CCriticalSection *pCriticalSection)
	: m_criticalSection(pCriticalSection)
{
	m_criticalSection->Lock();
}

CLocker::~CLocker(void)
{
	m_criticalSection->Unlock();
}


